{extend name="homeheader:header"/}
{block name="content"}
	<link rel="stylesheet" type="text/css" href="/home/css/index.css" />
	<body style="overflow-x: hidden;">
		<div class="index row">
			<div class="container-fluid">
				<div class="search row">
					<form action="{:url('/home/search/search')}" method="post">
						<input type="text" name="keyword" id="g_name" value="" placeholder="请输入搜索内容" class="col-xs-9" />
						<button class="col-xs-3" id="search">搜索</button>
						<i class="iconfont icon-sousuo"></i>
					</form>
				</div>
				<div class="layui-carousel" id="test1">
				  <div carousel-item>
				  	{foreach name="flash" item="vo"}
					<div><a href="{:url('/home/goods/goodDetail',array('id'=>$vo['gid']))}"><img src="{$vo.pic}"/></a></div>
					{/foreach}
				</div>
				</div>
				<div class="section">
					<div class="class">
						<ul class="row">
							<li class="col-xs-3">
								<a href="{:url('/home/goods/category')}">
									<div>
										<i class="iconfont">&#xe604;</i>
									</div>
									<p>水族类</p>
								</a>
							</li>
							<li class="col-xs-3">
								<a href="{:url('/home/goods/category')}">
									<div><i class="iconfont">&#xe627;</i></div>
									<p>宠物类</p>
								</a>
							</li>
							<li class="col-xs-3">
								<a href="{:url('/home/index/apply')}">
									<div><i class="iconfont">&#xe60e;</i></div>
									<p>专柜申请</p>
								</a>
							</li>
							<li class="col-xs-3">
								<a href="{:url('/home/index/partner')}">
									<div><i class="iconfont">&#xe61b;</i></div>
									<p>合伙人</p>
								</a>
							</li>
						</ul>
					</div>
					<div class="tuangou">
						<h3>团购拼单</h3>
						<ul class="row groupgoods">
							
						</ul>
					</div>
					<div class="guanggao">
						<h3>超值热卖</h3>
						<div class="row box">
							<div class="col-xs-5">
								{if condition="$advertsleft neq null"}
									<a href="{:url('/home/goods/goodsDetail',array('id'=>$advertsleft['gid']))}" style="display: block;">
										<img src="{$advertsleft.pic}"/>
									</a>
								{else/}
									<p>暂时无数据</p>
								{/if}
							</div>
							<div class="col-xs-6">
								<div class="row">
									<div class="col-xs-12">
										{if condition="$advertstop neq null"}
											<a href="{:url('/home/goods/goodsDetail',array('id'=>$advertstop['gid']))}" style="display: block;">
												<img src="{$advertstop.pic}"/>
											</a>
										{else/}
											<p>暂时无数据</p>
										{/if}
									</div>

									{if condition="$advertsbuttom neq null"}
										{volist name="advertsbuttom" id="vo"}
										<div class="col-xs-6">
											<a href="{:url('/home/goods/goodsDetail',array('id'=>$vo['gid']))}" style="display: block;">
												<img src="{$vo.pic}"/>
											</a>
										</div>
										{/volist}
									{/if}
								</div>
							</div>
						</div>
					</div>
					<div class="newest">
						<h3>新品发布</h3>
						<ul class="newsgoods">

						</ul>
					</div>
				</div>
			</div>
			<div class="footer">
				<ul class="row">
					<li class="col-xs-2 active">
						<a href="{:url('/home/index/index')}">
							<i class="iconfont icon-shouye"></i> <span>首页</span>
						</a>
					</li>
					<li class="col-xs-2">
						<a href="{:url('/home/goods/category')}">
							<i class="iconfont icon-icon"></i> <span>分类</span>
						</a>
					</li>
					<li class="col-xs-2">
						<a href="custom.html"><i class="iconfont icon-service"></i><span>客服</span>
						</a>
					</li>
					<li class="col-xs-2">
						<a href="{:url('/home/carts/carts')}"><i class="iconfont icon-cart1"></i> <span>购物车</span>
						</a>
					</li>
					<li class="col-xs-2">
						<a href="{:url('/home/user/home')}"><i class="iconfont icon-wode"></i> <span>我的</span>
						</a>
					</li>
				</ul>
			</div>
			<div class="ft_bg">
				<img src="/home/img/footer_bg.png"/>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		$(".class ul li a div").height($(".class ul li a div").width() + "px")
		$(".class ul li a div").css("line-height", $(".class ul li a div").height() + "px");
		$(".guanggao .box .col-xs-5 img").height($(".guanggao .box").height()+"px")
		layui.use('carousel', function(){
  var carousel = layui.carousel;
  //建造实例
  carousel.render({
    elem: '#test1'
    ,width: '100%' //设置容器宽度
    ,arrow: 'always' //始终显示箭头
    ,trigger:'touch'
    ,indicator:'none'
    ,autoplay:'true'
    ,arrow:'none'
  });
});
	</script>
	<script>
		/* 团购商品 */
		$.ajax({
			type:"post",
			url:"{:url('/home/index/getGroupGoods')}",
			async:false,
			contentType:"application/json",
			success:function(res){
				var data = res.data;
				for(var i=0;i<data.length;i++){
					var obj = new Function("return" + data[i].g_pic)();
					var imgurl = obj.photos[0].url;
					var str = '<li class="col-xs-4">'
						   +'<a href="/home/goods/gbulkDetail/id/'+data[i].id+'">'
						   +'<div class="img"><img src='+imgurl+' />'
						   +'<p class="timedown'+i+'" id=time'+i+'></p></div>'
						   +'<div class="tx"><p>'+data[i].g_name+'</p>'
						   +'<p><span>￥'+data[i].g_cprice+'</span></p>'
						   +'<p><span>'+data[i].g_number+'人参加活动</span></p>'
						   +'</div></a></li>';

					$('.groupgoods').append(str);
					var times = data[i].lefttime;
					var gid = data[i].id;
					var r = /^[0-9]*[1-9][0-9]*$/
					if(r.test(times) == false){
						$.post('/home/index/editGoodsStatus',{id:gid},function(r){

						},'json');
					}else{
						
						var tlis=$(".timedown"+i+"");
							let llllls=tlis;
						var timeid = window.setInterval(function () {
							for(var k=0;k<data.length;k++){
								var times=data[k].lefttime
							var day=00,
							hour = 00,
							minute = 00,
							second = 00;
							if (times > 0) {
							day = Math.floor(times/(60 * 60 * 24));
							hour = Math.floor(times/(60*60)) % 24; 
							minute = Math.floor(times / (60)) % 60;
							second = Math.floor(times) % 60;
							}
							if(times < 0)  {
								window.clearInterval(timeid);
							}
							if (day <= 9) day = '0' + day;
							if (hour <= 9) hour = '0' + hour;
							if (minute <= 9) minute = '0' + minute;
							if (second <= 9) second = '0' + second;
							$(".timedown"+k+"").html('<span>'+day+'</span>:<span>'+hour+'</span>:<span>'+minute+'</span>:<span>'+second+'</span>');
							times--;
							}
							
						}, 1000);
					
					}
				}	
			},
			error:function(res){

			}
		});

		/* 最新商品 */
		$.ajax({
			type:"post",
			url:"{:url('/home/index/getSellGoods')}",
			async: false,
			contentType:"application/json",
			success:function(res){		
				var data = res.data;
				var str = '';
				for(var i=0;i<data.length;i++){
					var obj = new Function("return" + data[i].g_pic)();
					imgurl = obj.photos[0].url;
					str += '<a href="/home/goods/goodsDetail/id/'+data[i].id+'"><li><img src='+imgurl+' /></li></a>';
				}

				$('.newsgoods').append(str);
			}
		});
	</script>
</html>
{/block}